#include <iostream>
using namespace std;

// 定义一个函数来进行加法运算
double add(double a, double b) {
    return a + b;
}

// 定义一个函数来进行减法运算
double subtract(double a, double b) {
    return a - b;
}

// 定义一个函数来进行乘法运算
double multiply(double a, double b) {
    return a * b;
}

// 定义一个函数来进行除法运算
double divide(double a, double b) {
    if (b == 0) {
        throw runtime_error("Division by zero error.");
    }
    return a / b;
}

// 主函数
int main() {
    double num1, num2;
    char operation;
    double result;

    cout << "Simple Calculator" << endl;
    cout << "-----------------" << endl;
    cout << "Enter the first number: ";
    cin >> num1;
    cout << "Enter the second number: ";
    cin >> num2;
    cout << "Enter the operation (+, -, *, /): ";
    cin >> operation;

    try {
        switch (operation) {
            case '+':
                result = add(num1, num2);
                break;
            case '-':
                result = subtract(num1, num2);
                break;
            case '*':
                result = multiply(num1, num2);
                break;
            case '/':
                result = divide(num1, num2);
                break;
            default:
                throw runtime_error("Invalid operation.");
        }

        cout << "Result: " << result << endl;
    } catch (const runtime_error& e) {
        cerr << "Error: " << e.what() << endl;
    }

    return 0;
}